import common.CommonDemo;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

/**
 * 获取当前url
 */
public class GetCurrentUrl {

    CommonDemo commonDemo = new CommonDemo();
    private ChromeDriver driver;
    private String webUrl;

    @BeforeTest
    public void setUp() throws Exception{
        //获取chromedriver
        driver = commonDemo.getChromeDriver();
        webUrl = commonDemo.getPropertyValue("config.properties", "web.url.baidu");
    }

    @Test
    public void test(){
        driver.get(webUrl);
        String currentUrl = driver.getCurrentUrl();
        System.out.println(currentUrl);
    }

    @AfterClass
    public void tearDown() throws Exception{
        Thread.sleep(2000);
        driver.quit();
    }
}
